1 using System;
2 using
UnityEngine;
3
4 namespace
ProceduralToolkit.Examples
5 {
6     
[Serializable]
7     
public class NameGenerator
8     {
9         
public string[] femaleNames = new string[0];
10         
public string[] maleNames = new string[0];
11         
public string[] lastNames = new string[0];
12
13         
public string femaleName { get { return femaleNames.GetRandom(); } }
14         
public string maleName { get { return maleNames.GetRandom(); } }
15         
public string firstName { get { return RandomE.Chance(0.5f) ? femaleName : maleName; } }
16         
public string lastName { get { return lastNames.GetRandom(); } }
17         
public string fullName { get { return string.Format("{0} {1}", firstName, lastName); } }
18
19         ///
<param name="namesJson">JSON file with string arrays for femaleNames, maleNames and lastNames</param>
20         
public NameGenerator(TextAsset namesJson)
21         {
22             JsonUtility.FromJsonOverwrite(namesJson.text,
this);
23         }
24     }
25 }


Gõ tìm kiếm nhanh...